///////////////////////////////////////////////////////////
// 
//  MyStage.cpp
//
//  Wiicussion
//  HCI 575 Class project
//  Spring 2007
// 
//  Authors:  Jeremy Bennett
//            Adam Faeth
//            Michael Oren
//
//  This class developed for Adam's 557 project
//
///////////////////////////////////////////////////////////


// Local Includes
#include "stdafx.h"
#include "MyStage.h"
#include "MyContext.h"

// SDL Includes
#include <SDL_opengl.h>

// System Includes
#include <vector>

// Constructor
MyStage::MyStage()
: _uiActInst(0)
{
    // do nothing
}

// Constructor
MyStage::MyStage(float fX, float fY, float fW, float fH)
: _uiActInst(0)
{
    _fRenderPos[0] = fX;
    _fRenderPos[1] = fY;
    
    _fRenderSize[0] = fW;
    _fRenderSize[1] = fH;
}


// destructor
MyStage::~MyStage()
{
}



bool
MyStage::init()
{
    return true;
}

bool
MyStage::setPos(float fX, float fY, float fW, float fH)
{
    _fRenderPos[0] = fX;
    _fRenderPos[1] = fY;
    
    _fRenderSize[0] = fW;
    _fRenderSize[1] = fH;
    return true;
}


// define the instruments and their positions
bool
MyStage::loadStage()
{
    _vInsts.resize(NUM_INSTS);
    
    for(unsigned int i = 0; i < _vInsts.size(); i++) {
        _vInsts[i].set(i, 110+i*216.0f, 150.0f, 0.0f);
    }
    
    return true;
}


bool 
MyStage::renderStage(MyContext * pContext)
{
    glPushAttrib(GL_ENABLE_BIT | GL_VIEWPORT_BIT);
    glPushMatrix();
    glLoadIdentity();
    
    glViewport(_fRenderPos[0], _fRenderPos[1], _fRenderSize[0], _fRenderSize[1]);

    
    float fBGcolor[] = {0.3f, 1.0f, 0.3f};
    glColor3fv(fBGcolor);
    
    // render the instruments
    for(size_t i = 0; i < _vInsts.size(); i++) {
        _vInsts[i].renderInstrument(pContext);
    }
    
    glPopMatrix();
    glPopAttrib();
    return true;
}

